package com.hg.design.structure.composite.biancheng.ex1;

public class CompositePattern {
    public static void main(String[] args) {
        Component c0 = new Composite();
        Component c1 = new Composite();
        Component c2 = new Composite();
        Component c3 = new Composite();
        Component leaf1 = new Leaf("1");
        Component leaf2 = new Leaf("2");
        Component leaf3 = new Leaf("3");
        Component leaf4 = new Leaf("4");
        Component leaf5 = new Leaf("5");
        Component leaf6 = new Leaf("6");
        c0.add(leaf1);
        c0.add(c1);
        c1.add(leaf2);
        c1.add(leaf3);
        c1.add(c2);
        c2.add(leaf6);
        c2.add(c3);
        c3.add(leaf4);
        c3.add(leaf5);
        c0.operation();
        System.out.println();
        c1.operation();
        System.out.println();
        c2.operation();
        System.out.println();
        c3.operation();
    }
}
